<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
 * CodeIgniter
 *
 * An open source application development framework for PHP 4.3.2 or newer
 *
 * @package        CodeIgniter
 * @author        Rick Ellis
 * @copyright    Copyright (c) 2006, EllisLab, Inc.
 * @license        http://www.codeignitor.com/user_guide/license.html
 * @link        http://www.codeigniter.com
 * @since        Version 1.0
 * @filesource
 */

// ------------------------------------------------------------------------

class Send_mail {

	function Send_mail()
	{
		$this->CI =& get_instance();
	}

	/**
	* hàm gửi email có templates
	* author khanhdq119@gmail.com
	* @param mixed $email_Tpl
	* @param mixed $email
	* @param mixed $args
	*/
    function sendMailNoTpl($email="nobody@domain.com",$subject='',$content,$toCC='')
	{
		require(APPPATH."ext_libraries/phpmailer/class.phpmailer.php");
		$mail = new PHPMailer();
		$mail->IsSMTP();
		try {
            $mail->Host       = ""; // SMTP server
            $mail->SMTPDebug  = 0;                     // enables SMTP debug information (for testing)
                                                       // 1 = errors and messages
                                                       // 2 = messages only
            $mail->SMTPAuth   = true;                  // enable SMTP authentication
            $mail->SMTPSecure = 'ssl';
            $mail->Host       = ""; // sets the SMTP server
            $mail->Port       = 465;                    // set the SMTP port for the GMAIL server
            $mail->Username   = ""; // SMTP account username
            $mail->Password   = "";        // SMTP account password
            $mail->CharSet	  = "utf-8";
            $mail->SetFrom('', 'TOYZ');
            if($toCC){
                $mail->AddCC($toCC,"TOYZ");
            }
            ($subject) ? $subject : 'TOYZ';
            $mail->Subject    = $subject." vào lúc ". date("g:i a F j, Y") ;
            //$mail->Subject    = $subject;

            $mail->AltBody    = ""; // optional, comment out and test

            $address = $email;
            $mail->AddAddress($email, "TOYZ");
            $mail->IsHTML(true);
            $mail->Body    = stripslashes($content);
            $mail->Send();
            return TRUE;
		} catch (phpmailerException $e) {
	  		return FALSE; //Pretty error messages from PHPMailer
		} catch (Exception $e) {
			return FALSE; //Boring error messages from anything else!
		}
		unset($subject);
		unset($content);
		unset($receivers);
		unset($mail);
	}
}